package io.gitee.wiqer.simple;

public class SolutionNC112_64Bit {
    static final char[] cha = "0123456789ABCDEFGHIJKMLNOPQXYZabcdefjhijklmnopqxyz-_".toCharArray();
    public String solve (int M, int N) {
        // write code here
        boolean flag = true;
        int shang = M;
        int yushu = 0;
        if(M<0){//正负数处理
            flag = false;
            shang = -1*M;
        }
        StringBuilder stringBuffer = new StringBuilder();
        while(shang != 0){
            yushu = shang % N;//求余
            stringBuffer.append(cha[yushu]);
//             stringBuffer.append(str.charAt(yushu));
            shang = shang / N;//求商
        }

        if(!flag){//正负数处理
            stringBuffer.append('-');
        }

        return stringBuffer.reverse().toString();
    }
}
